<?php
namespace serv\task\warehouse;

use L;
use of\base\com\mq;

class inbound
{
    // 获取入库单详情
    public static function inboundOrder()
    {
        $startDate = date('Y-m-d H:i:s', strtotime('-6 months'));
        $sql = "SELECT
                    `total_qty`, 
                    `platform_no`,
                    `to_warehouse`,
                    `transfer_order_id`,
                    `to_type`
                FROM
                    `transfer_order` 
                WHERE
                    `created_at` >= '{$startDate}'";
        $rows = L::sql($sql, 'warehouse');
        if (!empty($rows)) {
            $service = [40 => 'Fop', 30 => 'Winit'];
            foreach ($rows as $row) {
                if (!empty($row['platform_no'])) {
                    $data = [
                        'service' => $service[$row['to_type']] ?? '',
                        'total_qty' => $row['total_qty'],
                        'platform_no' => $row['platform_no'],
                        'transfer_order_id' => $row['transfer_order_id'],
                    ];
                    echo json_encode($data);exit;
                    $key = "inboundQueue_{$row['transfer_order_id']}";
                    mq::set(["inboundQueue", $key], $data);
                }
            }
        }
    }

}
